package com.ssy.lingxi.pay.controller.pc.allInPay;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.pay.api.model.vo.request.allInPay.*;
import com.ssy.lingxi.pay.api.model.vo.response.allInPay.AllInPayMemberRespVO;
import com.ssy.lingxi.pay.entity.allInPay.AllInPayBank;
import com.ssy.lingxi.pay.model.vo.request.UserInfoReqVO;
import com.ssy.lingxi.pay.model.vo.response.UserAuthInfoVO;
import com.ssy.lingxi.pay.service.allInPay.IAllInPayService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 通联支付-e账户会员认证控制类
 * @author lqa
 * @version 2.0.0
 * @date 2021/11/26
 */
@RestController
@RequestMapping("/pay/allInPay")
public class AllInPayController extends BaseController {
    @Resource
    private IAllInPayService payService;

//    /**
//     * 通联支付-确认支付(后台+短信验证码确认)-重发支付短信验证码
//     * 收银宝网关支付时需要用到
//     * @return 操作结果
//     */
//    @RequestMapping(value = "/resendPaySMS", method = RequestMethod.POST)
//    public Wrapper<ResendPaySMSRespVO> resendPaySMS(@RequestBody ResendPaySMSVO resendPaySMSVO) {
//        return  Wrapper.success(payService.resendPaySMS( resendPaySMSVO));
//
//    }
//
//    /**
//     * 确认支付（前台+短信验证码确认）
//     * 收银宝网关支付时需要用到
//     *
//     * @return 跳转链接
//     */
//    @RequestMapping(value = "/gateWayPay", method = RequestMethod.POST)
//    public Wrapper<String> gateWayPay(@RequestBody GateWayPayVO gateWayPayVO) {
//        return Wrapper.success(payService.gateWayPay(getSysUser(), gateWayPayVO));
//    }
//
//    /**
//     * 通联支付-确认支付(后台+短信验证码确认)
//     * 企业用户使用设置的对公户提现流或者提现到法人个人银行卡时要调用该接口
//     *收银宝快捷支付,余额时需要用到
//     * @return 操作结果
//     */
//    @RequestMapping(value = "/confirmPay", method = RequestMethod.POST)
//    public Wrapper<PayRespVO> confirmPay(@RequestBody @Valid PayVO vo) {
//        return Wrapper.success(payService.pay(getSysUser(), vo));
//    }


    /**
     * 获取通联会员绑定的手机号码
     *
     * @return 操作结果
     */
    @RequestMapping(value = "/getUserPhone", method = RequestMethod.POST)
    public Wrapper<String> getUserPhone(@RequestBody @Valid UserInfoReqVO userInfoReqVO) {
        return Wrapper.success(payService.getUserPhone(userInfoReqVO));
    }

    /**
     * 查询个人会员是否实名验证或,企业会员是否完成企业审核
     *
     * @return 操作结果
     */
    @RequestMapping(value = "/getUserInfo", method = RequestMethod.POST)
    public Wrapper<UserAuthInfoVO> getUserInfo(@RequestBody @Valid UserInfoReqVO userInfoReqVO) {
        return Wrapper.success(payService.getUserInfo(userInfoReqVO));
    }

    /**
     * 银行列表
     *
     * @return 操作结果
     */
    @RequestMapping(value = "/getBankList", method = RequestMethod.GET)
    public Wrapper<List<AllInPayBank>> getBankList() {
        return Wrapper.success(payService.getBankList());
    }


    /**
     * 通联支付-设置或修改或重置支付密码【密码验证版】
     *
     * @return 操作结果
     */
    @RequestMapping(value = "/setPayPwd", method = RequestMethod.POST)
    public Wrapper<String> setPayPwd(@RequestBody SetPayPwdVO vo) {
        return payService.setPayPwd(getSysUser(), vo);
    }


//    /**
//     * 通联支付-冻结/解冻金额
//     *
//     * @return 操作结果
//     */
//    @RequestMapping(value = "/freezeMoney", method = RequestMethod.POST)
//    public Wrapper<FreezeMoneyRespVO> freezeMoney(@RequestBody FreezeMoneyReqVO vo) {
//        UserLoginCacheDTO sysUser = getSysUser();
//        return Wrapper.success(payService.freezeMoney(sysUser.getMemberId(), sysUser.getMemberRoleId(), vo));
//    }
//
//    /**
//     * 通联支付-查询账户收支明细
//     *
//     * @return 操作结果
//     */
//    @RequestMapping(value = "/queryInExpDetail", method = RequestMethod.POST)
//    public Wrapper<QueryInExpDetailRespVO> queryInExpDetail(@RequestBody QueryInExpDetailDTO dto) {
//        UserLoginCacheDTO sysUser = getSysUser();
//        return Wrapper.success(payService.queryInExpDetail(sysUser.getMemberId(), sysUser.getMemberRoleId(), dto));
//    }
//
//    /**
//     * 通联支付-查询余额
//     *
//     * @return 操作结果
//     */
//    @RequestMapping(value = "/queryBalance", method = RequestMethod.GET)
//    public Wrapper<BalanceVO> queryBalance() {
//        UserLoginCacheDTO sysUser = getSysUser();
//        return Wrapper.success(payService.queryBalance(sysUser.getMemberId(), sysUser.getMemberRoleId()));
//    }

    /**
     * 通联支付-会员绑定支付账户用户标识
     *
     * @return 操作结果
     */
    @RequestMapping(value = "/applyBindAcct", method = RequestMethod.POST)
    public Wrapper<Void> applyBindAcct(@RequestBody @Valid ApplyBindAcctVO vo) {
        return payService.applyBindAcct(getSysUser(), vo);
    }

    /**
     * 通联支付-影印件采集
     *
     * @return 操作结果
     */
    @RequestMapping(value = "/idCardCollect", method = RequestMethod.POST)
    public Wrapper<Object> idCardCollect(@Valid @RequestBody IdCardCollectVO idCardCollectVO) {
        return payService.idCardCollect(getSysUser(), idCardCollectVO);
    }

    /**
     * 支付能力-支付方式管理-e账户认证-企业账户认证-提交企业信息-进一步提交信息
     *
     * @author lqa
     * @date 2021/11/26
     **/
    @RequestMapping(value = "/submitEnterPriseMember", method = RequestMethod.POST)
    public Wrapper<Void> submitEnterPriseMember(@Valid @RequestBody AllInPaySubmitEnterPriseMemberReqVO vo) {
        return payService.submitEnterPriseMember(getSysUser(), vo);
    }

    /**
     * 支付能力-支付方式管理-e账户认证-企业账户认证-提交企业信息
     *
     * @author lqa
     * @date 2021/11/26
     **/
    @RequestMapping(value = "/addEnterPriseMember", method = RequestMethod.POST)
    public Wrapper<Void> addEnterPriseMember(@Valid @RequestBody AllInPayEnterPriseMemberReqVO allInPayEnterPriseMemberReqVO) {
        return payService.addEnterPriseMember(getSysUser(), allInPayEnterPriseMemberReqVO);
    }

    /**
     * 支付能力-支付方式管理-e账户认证-获取个人或企业用户信息
     *
     * @return 用户信息
     */
    @RequestMapping(value = "/getAuthMemberInfo", method = RequestMethod.GET)
    public Wrapper<AllInPayMemberRespVO> getAuthMemberInfo() {
        return Wrapper.success(payService.getAuthMemberInfo(getSysUser()));
    }

    /**
     * 通联支付-获取会员信息
     *
     * @return 会员信息
     */
    @RequestMapping(value = "/getMemberInfo", method = RequestMethod.POST)
    public Wrapper<AllInPayMemberRespVO> getMemberInfo() {
        return Wrapper.success(payService.getMemberInfo(getSysUser()));
    }

    /**
     * 通联支付-企业会员绑定对公户
     *
     * @param bindCompanyAccountVO 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/bindCompanyAccount", method = RequestMethod.POST)
    public Wrapper<Void> bindCompanyAccount(@Valid @RequestBody BindCompanyAccountVO bindCompanyAccountVO) {
        return payService.bindCompanyAccount(getSysUser(), bindCompanyAccountVO);
    }

    /**
     * 通联支付-设置企业信息
     *
     * @param allInPayEnterPriseMemberReqVO 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/setCompanyInfo", method = RequestMethod.POST)
    public Wrapper<Void> setCompanyInfo(@Valid @RequestBody AllInPayEnterPriseMemberReqVO allInPayEnterPriseMemberReqVO) {
        return payService.setCompanyInfo(getSysUser(), allInPayEnterPriseMemberReqVO);
    }
    //*******************************个人认证所需要的接口*********************************

    /**
     * 支付能力-支付方式管理-e账户认证-个人账户认证-修改个人信息
     *
     * @author lqa
     * @date 2021/11/26
     **/
    @RequestMapping(value = "/updatePersonal", method = RequestMethod.POST)
    public Wrapper<Void> updatePersonal(@Valid @RequestBody AllInPayUpdatePersonalReqVO allInPayUpdatePersonalReqVO) {
        return payService.updatePersonal(getSysUser(), allInPayUpdatePersonalReqVO);
    }

    /**
     * 通联支付-解绑绑定银行卡
     *
     * @param unBindPhoneVO 银行卡号
     * @return 操作结果
     */
    @RequestMapping(value = "/unbindBankCard", method = RequestMethod.POST)
    public Wrapper<Void> unbindBankCard(@RequestBody @Valid UnBindPhoneVO unBindPhoneVO) {
        return payService.unbindBankCard(getSysUser(), unBindPhoneVO);
    }

    /**
     * 通联支付-解绑手机（验证原手机短信验证码）
     *
     * @param bindPhoneVO 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/unbindPhone", method = RequestMethod.POST)
    public Wrapper<Void> unbindPhone(@Valid @RequestBody BindPhoneVO bindPhoneVO) {
        return payService.unbindPhone(getSysUser(), bindPhoneVO);
    }

    /**
     * 支付能力-支付方式管理-e账户认证-个人账户认证-进一步信息提交
     *
     * @author lqa
     * @date 2021/11/26
     **/
    @RequestMapping(value = "/submitPersonal", method = RequestMethod.POST)
    public Wrapper<Void> submitPersonal(@Valid @RequestBody BankCardVO bankCardVO) {
        return payService.submitPersonal(getSysUser(), bankCardVO);
    }


    /**
     * 通联支付-绑定银行卡
     *
     * @param bindBankCardVO 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/bindBankCard", method = RequestMethod.POST)
    public Wrapper<Void> bindBankCard(@Valid @RequestBody BindBankCardVO bindBankCardVO) {
        return payService.bindBankCard(getSysUser(), bindBankCardVO);
    }

    /**
     * 通联支付-请求绑定银行卡
     *
     * @param vo 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/applyBindBankCard", method = RequestMethod.POST)
    public Wrapper<Object> applyBindBankCard(@Valid @RequestBody ApplyBindBankCardVO vo) {
        return payService.applyBindBankCard(getSysUser(), vo);
    }

    /**
     * 通联支付-会员电子协议签约查询
     *
     * @return 返回页面跳转url
     */
    @RequestMapping(value = "/signContractQuery", method = RequestMethod.POST)
    public Wrapper<String> signContractQuery(@RequestBody SignContractVO signContractVO) {
        return payService.signContractQuery(getSysUser(), signContractVO);
    }

    /**
     * 通联支付-会员电子协议签约
     *
     * @return 返回页面跳转url
     */
    @RequestMapping(value = "/signContract", method = RequestMethod.POST)
    public Wrapper<String> signContract(@RequestBody SignContractVO signContractVO) {
        return payService.signContract(getSysUser(), signContractVO);
    }

    /**
     * 支付能力-支付方式管理-e账户认证-个人账户认证
     *
     * @author lqa
     * @date 2021/11/26
     **/
    @RequestMapping(value = "/personalCrate", method = RequestMethod.POST)
    public Wrapper<Void> personalCrate(@Valid @RequestBody AllInPayPersonalAuthReqVO authReqVO) {
        return payService.personalCrate(getSysUser(), authReqVO);
    }

    /**
     * 通联支付-个人实名验证
     *
     * @param authReqVO 请求参数
     * @return 个人是否实名验证成功
     */
    @RequestMapping(value = "/setRealName", method = RequestMethod.POST)
    public Wrapper<Void> setRealName(@Valid @RequestBody AllInPayPersonalAuthReqVO authReqVO) {
        return payService.setRealName(getSysUser(), authReqVO);
    }

    /**
     * 通联支付-绑定手机
     *
     * @return 绑定手机是否成功
     */
    @RequestMapping(value = "/bindPhone", method = RequestMethod.POST)
    public Wrapper<Void> bindPhone(@Valid @RequestBody BindPhoneVO bindPhoneVO) {
        return payService.bindPhone(getSysUser(), bindPhoneVO);
    }

    /**
     * 通联支付-发送短信验证码
     *
     * @return 操作结果
     */
    @RequestMapping(value = "/sendVerificationCode", method = RequestMethod.POST)
    public Wrapper<Void> sendVerificationCode(@Valid @RequestBody SendVerificationCodeVO sendVerificationCodeVO) {
        return payService.sendVerificationCode(getSysUser(), sendVerificationCodeVO);
    }

    /**
     * 通联支付-创建会员
     *
     * @return 操作结果
     */
    @RequestMapping(value = "/createMember", method = RequestMethod.POST)
    public Wrapper<Void> createMember() {
        return payService.createMember(getSysUser());
    }

}
